package com.ruoyi.exam.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.exam.domain.ExamArchive;
import com.ruoyi.exam.service.IExamArchiveService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考试任务归档管理Controller
 * 
 * @author ruoyi
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/exam/taskArchive")
public class ExamArchiveController extends BaseController
{
    @Autowired
    private IExamArchiveService examArchiveService;

    /**
     * 查询考试任务归档管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:taskArchive:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExamArchive examArchive)
    {
        startPage();
        List<ExamArchive> list = examArchiveService.selectExamArchiveList(examArchive);
        return getDataTable(list);
    }

    /**
     * 导出考试任务归档管理列表
     */
    @PreAuthorize("@ss.hasPermi('exam:taskArchive:export')")
    @Log(title = "考试任务归档管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExamArchive examArchive)
    {
        List<ExamArchive> list = examArchiveService.selectExamArchiveList(examArchive);
        ExcelUtil<ExamArchive> util = new ExcelUtil<ExamArchive>(ExamArchive.class);
        util.exportExcel(response, list, "考试任务归档管理数据");
    }

    /**
     * 获取考试任务归档管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('exam:taskArchive:query')")
    @GetMapping(value = "/{archiveId}")
    public AjaxResult getInfo(@PathVariable("archiveId") Long archiveId)
    {
        return success(examArchiveService.selectExamArchiveByArchiveId(archiveId));
    }

    /**
     * 新增考试任务归档管理
     */
    @PreAuthorize("@ss.hasPermi('exam:taskArchive:add')")
    @Log(title = "考试任务归档管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExamArchive examArchive)
    {
        return toAjax(examArchiveService.insertExamArchive(examArchive));
    }

    /**
     * 修改考试任务归档管理
     */
    @PreAuthorize("@ss.hasPermi('exam:taskArchive:edit')")
    @Log(title = "考试任务归档管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExamArchive examArchive)
    {
        return toAjax(examArchiveService.updateExamArchive(examArchive));
    }

    /**
     * 删除考试任务归档管理
     */
    @PreAuthorize("@ss.hasPermi('exam:taskArchive:remove')")
    @Log(title = "考试任务归档管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{archiveIds}")
    public AjaxResult remove(@PathVariable Long[] archiveIds)
    {
        return toAjax(examArchiveService.deleteExamArchiveByArchiveIds(archiveIds));
    }
}
